<?php
$isReloadable = true;
require_once("../../pers/inc.config.php");
require_once(OVF_FS_WEB_ROOT.'/app/_inc/inc.session.php');
require_once(OVF_FS_WEB_ROOT.'/app/_inc/funct.html.php');
$objSess->setReqSV('agenda', 'dataAge', date('d/m/Y'));

$sSql = "SELECT a.*, au.id_utente, u.nome, u.cognome FROM ovf_agenda a "
	." LEFT JOIN ovf_agenda_utenti au ON au.id_agenda = a.id_agenda "
	." LEFT JOIN ovf_utenti u ON u.id_utente = au.id_utente "
	." WHERE a.id_agenda = ".reqVarInt('id');
$objDB->query($sSql,'selAge');	
if (!$acAge = $objDB->fetch('selAge')) {
	backOnErr("id '".reqVar('id')."' errato");
}
$acX = $acAge;
$aAgende = array();
while($acX) {
	$aAgende[$acX['id_utente']] = $acX['nome']." ".$acX['cognome'];
	$acX = $objDB->fetch('selAge');
}
$agendeTxt = implode(", ",$aAgende);

if (reqVar('azione') == 'elimina') {
	$msgPag = confEli();
} else {
}
$aOre = array('08'=>'08','09'=>'09','10'=>'10','11'=>'11','12'=>'12','13'=>'13','14'=>'14','15'=>'15'
	,'16'=>'16','17'=>'17','18'=>'18','19'=>'19','20'=>'20','21'=>'21','22'=>'22','23'=>'23'
	,'00'=>'00','01'=>'01','02'=>'02','03'=>'03','04'=>'04','05'=>'05','06'=>'06','07'=>'07');
$aMin = array('00'=>'00','15'=>'15','30'=>'30');
$aRipeti = array(''=>'non ripetere','a'=>'ogni anno','m'=>'ogni mese','g'=>'ogni giorno');
$aPOP = array('pub'=>'pubblico','occ'=>'occupato','pri'=>'privato');

$sCmdR = '';
$sCmdR .= "&nbsp;&nbsp;&nbsp;";
$sCmdR .= "<a class=\"cmd1\" href=\"javascript:confEli();\" >elimina</a>\n";
$sCmdR .= "&nbsp;&nbsp;&nbsp;";
$sCmdR .= "<a class=\"cmd1\" href=\"javascript:goModif();\" >modifica</a>\n";
$sCmdR .= cmdTorna('torna'); 

testaHtml('Agenda','Visualizza memo',$msgPag,'agen');
?>
<script type="text/javascript">
<!--
function goModif() {
	document.frm1.action = 'memoMod.php';
	document.frm1.submit();	
}
function confEli() {
	if (confirm("confermi l'eliminazione ?")) {
		document.frm1.azione.value = 'elimina';
		document.frm1.submit();
	}
}
//-->
</script>
<table border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="cmd1" align="right"><?php echo $sCmdR;?></td>
   </tr>
</table>
<?=getHtmlForm('frm1','',array('enctype'=>true));?>
<?=getHtmlHidden('azione','');?>
<?=getHtmlHidden('id');?>
<?=getHtmlHidden('xsn',XSN);?>
<table class="tab1" border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
	<?=getHtmlRigaRif();?>
   <tr>
      <td class="tit1" colspan='20' align='center'>Memo</td>
   </tr>
   <tr>
      <td class="lab1" colspan='3' align='left'>Nell'agenda di</td>
      <td class="txt1" colspan='15' align='left'>
      <?php echo $agendeTxt;?>
		</td>
      <td class="txt1" colspan='2' align='center'>
      	<b><?php echo $aPOP[$acAge['pub_occ_pri']];?></b>
		</td>
   </tr>
   <tr>
      <td class="lab1" colspan='3' align='left'>Oggetto</td>
      <td class="txt1" colspan='17' align='left'>
      	<?php echo $acAge['oggetto']?>
		</td>
   </tr>
   <tr>
      <td class="lab1" colspan='3' align='left'>Data</td>
      <td class="txt1" colspan='3' align='left'>
      	<?php echo YMD2DMY($acAge['data_memo_iniz'])?>
		</td>
      <td class="lab1" colspan='1' align='left'>Ora</td>
      <td class="txt1" colspan='3' align='left'>
      	<?php echo lpad($acAge['ora'],2,'0').":".lpad($acAge['minuti'],2,'0');?>
		</td>
      <td class="lab1" colspan='1' align='left'>Ripeti</td>
      <td class="txt1" colspan='4' align='left'>
      <?php 
      if ($acAge['giorno']==0) echo 'ogni giorno'; 
      elseif ($acAge['mese']==0) echo 'ogno mese'; 
      elseif ($acAge['anno']==0) echo 'ogni anno'; 
      else echo 'non ripetere';
      ?>
		</td>
      <td class="lab1" colspan='1' align='left'>Fino a</td>
      <td class="txt1" colspan='4' align='left'>
      	<?php echo YMD2DMY($acAge['data_agenda']);?>
		</td>
	</tr>
   <tr>
      <td class="lab1" colspan='3' align='left'>Nota</td>
      <td class="txt1" colspan='17' align='left'>
      <?php echo getHtmlViewText($acAge['nota']);?>
		</td>
   </tr>
</table>
<table border="0" cellpadding="3" cellspacing="1" width="100%" align='center'>
   <tr>
      <td class="cmd1" align="right"><?php echo $sCmdR;?></td>
   </tr>
</table>
<?
echo "</form>\n";
codaHtml();
exit();

function confEli() {
	return "wip";
}
